package com.txy.test.domain.strategy.service.raffle;

import com.alibaba.fastjson.JSON;
import com.txy.domain.strategy.model.entity.RaffleAwardEntity;
import com.txy.domain.strategy.model.entity.RaffleFactorEntity;
import com.txy.domain.strategy.service.armory.IStrategyArmory;
import com.txy.domain.strategy.service.armory.IStrategyDispatch;
import com.txy.domain.strategy.service.raffle.DefaultRaffleServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RaffleService {

    @Resource
    private DefaultRaffleServiceImpl raffleService;

    @Resource
    private IStrategyArmory strategyArmory;

    @Before
    public void init() {
        strategyArmory.assembleLotteryStrategy(100006L);
    }

    @Test
    public void raffle() {
        RaffleAwardEntity raffleAwardEntity = raffleService.performRaffle(RaffleFactorEntity.builder()
                .strategyId(100006L)
                .userId("txy").build());
        log.info("raffle res: {}", JSON.toJSONString(raffleAwardEntity.toString()));
    }
}
